﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cash_desk_model;
using cash_desk_model.src.model;

namespace cash_desk
{
    public partial class TransactionsForm : Form
    {
        public TransactionsForm()
        {
            InitializeComponent();
        }

        private void TransactionsForm_Load(object sender, EventArgs e)
        {
            this.InitTransactionsGrid();
        }

        private void InitTransactionsGrid()
        {
            this.transactionsGrid.Rows.Clear();
            CashDeskService.SetupDBConn();
            CashDeskService service = new CashDeskService();
            List<Payment> transactions = service.GetTransactionsForSearch(0 , new DateTime(), null, null);
            CashDeskService.DestroyDBConn();

            for (int i = 0; i < transactions.Count; i++)
            {
                this.transactionsGrid.Rows.Add(
                    transactions[i].PaymentID,
                    transactions[i].PayType,
                    transactions[i].Amount,
                    transactions[i].CardID,
                    transactions[i].CasheirName,
                    transactions[i].PayDate);
            }
            CashDeskService.DestroyDBConn();
        }

        private void transactionsGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            SoldProductsForm soldProductsForm = new SoldProductsForm("1");
            soldProductsForm.Show();
        }
    }
}
